package com.meego.common.util;

import java.io.File;
import java.io.InputStream;
import java.net.URL;

public class ZipEntry {

    public static final int INPUTSTREAM = 1;
    public static final int FILE = 2;
    public static final int URL = 3;
    public static final int STRING = 4;
    private int entryType = 0;
    private String fileName;
    private URL url;
    private File file;
    private InputStream stream;
    private String content;

    public ZipEntry(String fileName, String content) throws Exception {
        if (content == null || content.isEmpty() || fileName == null || fileName.isEmpty()) {
            throw new IllegalArgumentException("Invalid parameters. Params can not be <null> or Empty");
        }
        this.entryType = STRING;
        this.content = content;
        this.fileName = fileName;
    }

    public ZipEntry(String fileName, URL url) throws Exception {
        if (url == null || fileName == null || fileName.isEmpty()) {
            throw new IllegalArgumentException("Invalid parameters. Params can not be <null> or Empty");
        }
        this.entryType = URL;
        this.fileName = fileName;
        this.url = url;
    }

    public ZipEntry(String fileName, InputStream stream) throws Exception {
        if (stream == null || fileName == null || fileName.isEmpty()) {
            throw new IllegalArgumentException("Invalid parameters. Params can not be <null> or Empty");
        }
        this.entryType = INPUTSTREAM;
        this.fileName = fileName;
        this.stream = stream;
    }

    public ZipEntry(String fileName, File file) throws Exception {
        if (file == null || fileName == null || fileName.isEmpty()) {
            throw new IllegalArgumentException("Invalid parameters. Params can not be <null> or Empty");
        }
        this.entryType = FILE;
        this.file = file;
        this.fileName = fileName;
    }

    public int getEntryType() {
        return entryType;
    }

    public String getFileName() {
        return fileName;
    }

    public URL getUrl() {
        return url;
    }

    public File getFile() {
        return file;
    }

    public InputStream getStream() {
        return stream;
    }

    public String getContent() {
        return content;
    }
}
